package com.naxian.service.Impl;

import com.naxian.mapper.CompanyMapper;
import com.naxian.mapper.RecruitMapper;
import com.naxian.pojo.Company;
import com.naxian.pojo.CompanyExample;
import com.naxian.pojo.Recruit;
import com.naxian.pojo.RecruitExample;
import com.naxian.service.index.IndexService;
import com.naxian.vo.index.IndexVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class IndexServiceImpl implements IndexService {
    @Autowired
    private CompanyMapper companyMapper;
    @Autowired
    private RecruitMapper recruitMapper;
    @Override
    //根据公司对象获得所有公司对应发出的招聘信息
    public  Map<Company,Recruit> indexGet(Company company) {
//        CompanyExample companyExample = new CompanyExample();
//        CompanyExample.Criteria companyCriteria = companyExample.createCriteria();
        List<Recruit> recruitList = new ArrayList<>();//创建招聘的集合
        Map<Company,Recruit> map = new HashMap<>();

        RecruitExample recruitExample = new RecruitExample();
        RecruitExample.Criteria recruitCriteria = recruitExample.createCriteria();
        recruitCriteria.andCompanyIdEqualTo(company.getCompanyId());
        recruitList = recruitMapper.selectByExample(recruitExample);//得到招聘的集合
        for (Recruit recruit:recruitList){
            map.put(company,recruit);
        }
        return map;
    }
}
